package com.ruoyi.checksystem.domain;

import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;

/**
 * 充值记录对象 recharge_record
 * 
 * @author ruoyi
 * @date 2025-03-21
 */
public class RechargeRecord extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 主键ID */
    private Long id;

    /** 关联用户ID */
    @Excel(name = "关联用户ID")
    private Long userId;

    /** 转账时的手机号 */
    @Excel(name = "转账时的手机号")
    private String phone;

    /** 充值额度（点数） */
    @Excel(name = "充值额度", readConverterExp = "点=数")
    private Integer amount;

    /** 充值套餐详情（JSON格式，{"duration": "365天", "price": 768, "points": 1000}） */
    @Excel(name = "充值套餐详情", readConverterExp = "J=SON格式，{\"duration\":\"365天\",\"price\":768,\"points\":1000}")
    private String packageDetails;


    /** 转账时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "转账时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date transferTime;

    /** 删除标记（1已删除，0未删除） */
    @Excel(name = "删除标记", readConverterExp = "1=已删除,0=未删除")
    private Object isDeleted;

    public void setId(Long id) 
    {
        this.id = id;
    }

    public Long getId() 
    {
        return id;
    }

    public void setUserId(Long userId) 
    {
        this.userId = userId;
    }

    public Long getUserId() 
    {
        return userId;
    }

    public void setPhone(String phone) 
    {
        this.phone = phone;
    }

    public String getPhone() 
    {
        return phone;
    }

    public void setAmount(Integer amount) 
    {
        this.amount = amount;
    }

    public Integer getAmount() 
    {
        return amount;
    }

    public void setPackageDetails(String packageDetails) 
    {
        this.packageDetails = packageDetails;
    }

    public String getPackageDetails() 
    {
        return packageDetails;
    }

    public void setTransferTime(Date transferTime) 
    {
        this.transferTime = transferTime;
    }

    public Date getTransferTime() 
    {
        return transferTime;
    }

    /**
     * 获取删除标记
     * @return 删除标记（1已删除，0未删除）
     */
    public Integer getIsDeleted() 
    {
        // 如果isDeleted是字符串类型的"Y"或"N"，则转换为整数
        if (isDeleted != null) {
            if (isDeleted instanceof String) {
                String strValue = (String) isDeleted;
                return "Y".equalsIgnoreCase(strValue) ? 1 : 0;
            } else if (isDeleted instanceof Integer) {
                return (Integer) isDeleted;
            } else {
                // 其他情况，尝试转换为整数
                try {
                    return Integer.parseInt(isDeleted.toString());
                } catch (Exception e) {
                    // 如果转换失败，则默认为0（未删除）
                    return 0;
                }
            }
        }
        return 0; // 默认未删除
    }

    /**
     * 设置删除标记 - 自动处理字符串和整数类型
     * @param isDeleted 删除标记（1或"Y"表示已删除，0或"N"表示未删除）
     */
    public void setIsDeleted(Object isDeleted) 
    {
        this.isDeleted = isDeleted;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("userId", getUserId())
            .append("phone", getPhone())
            .append("amount", getAmount())
            .append("packageDetails", getPackageDetails())
            .append("transferTime", getTransferTime())
            .append("createTime", getCreateTime())
            .append("updateTime", getUpdateTime())
            .append("isDeleted", getIsDeleted())
            .toString();
    }
}
